package org.jix.gbook.auth.constant;

/**
 * @author stark
 * @date 2025/5/12 13:46
 * @description
 **/
public class RedisKeyConstants {

    /**
     * 验证码前缀
     */
    public static final String VERIFICATION_CODE_KEY_PREFIX = "verification_code:";

    /**
     * 小黄书全局ID生成器
     */
    public static final String GBOOK_ID_GENERATOR_KEY = "gbook.id.generator";

    /**
     * 用户角色数据key前缀
     */
    public static final String USER_ROLES_KEY_PREFIX = "user:roles:";

    /**
     * 角色对应权限集合的key前缀
     */
    private static final String ROLE_PERMISSIONS_KEY_PREFIX = "role:permissions:";
    //----------------------------------------------------------------------------------//
    /**
     * 构建验证码key
     * @param phone
     * @return
     */
    public static String buildVerificationCodeKey(String phone) {
        return VERIFICATION_CODE_KEY_PREFIX + phone;
    }

    /**
     * 构建验证码key
     * @param phone
     * @return
     */
    public static String buildUserRoleKey(String phone) {
        return USER_ROLES_KEY_PREFIX + phone;
    }

    /**
     * 构建角色对应的权限集合 KEY
     * @param roleKey
     * @return
     */
    public static String buildRolePermissionsKey(String roleKey) {
        return ROLE_PERMISSIONS_KEY_PREFIX + roleKey;
    }

    /**
     * 用户对应的角色集合 KEY
     * @param userId
     * @return
     */
    public static String buildUserRoleKey(Long userId) {
        return USER_ROLES_KEY_PREFIX + userId;
    }

}
